package com.nuoniu.sibanyun.controller.erp;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.nuoniu.sibanyun.common.BaseController;
import com.nuoniu.sibanyun.common.result.HttpResult;
import com.nuoniu.sibanyun.entity.erp.ErpPda;
import com.nuoniu.sibanyun.service.erp.IErpPdaService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * pda设置 前端控制器
 * </p>
 *
 * @author 小啊刚
 * @since 2021-12-29
 */
@RestController
@RequestMapping("/erp/pda")
@Api(tags = "pda设置")
public class ErpPdaController extends BaseController {

    @Autowired
    private IErpPdaService pdaService;

    @ApiOperation("获取列表")
    @GetMapping("pageList")
    public HttpResult pageList(Page page) {
        return HttpResult.ok(pdaService.pageList(page));
    }

    @ApiOperation("获取当前使用的pda")
    @GetMapping("getUsePda")
    public HttpResult getUsePda() {
        return HttpResult.ok(pdaService.getUsePda());
    }

    @ApiOperation("保存")
    @PostMapping("save")
    public HttpResult save(@RequestBody ErpPda erpPda) {
        pdaService.savePda(erpPda);
        return HttpResult.ok();
    }

    @ApiOperation("删除")
    @PostMapping("delete")
    public HttpResult delete(@RequestBody List<Long> ids) {
        pdaService.removeByIds(ids);
        return HttpResult.ok();
    }

    @ApiOperation("启用/停用")
    @GetMapping("updateStatus")
    public HttpResult updateStatus(Long id, Integer status) {
        pdaService.updateStatus(id, status);
        return HttpResult.ok();
    }
}
